home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / MixedMode.mod < prev    next >
Encoding:
Text File  |  1995-08-10  |  8.1 KB  |  286 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        MixedMode.mod
  3.  
  4.      Contains:    Mixed Mode Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$TAGS-*)
  21. (*$CALLING PASCAL*)
  22. MODULE MixedMode;
  23.  
  24. IMPORT SYSTEM, Types;
  25.  
  26. (* $PUSH*)
  27. (* $ALIGN MAC68K*)
  28. (* $LibExport+*)
  29.  
  30. CONST
  31.     kRoutineDescriptorVersion*    = 7;
  32.  
  33. (* MixedModeMagic Magic Cookie/Trap number *)
  34.     _MixedModeMagic*                = $AAFE;
  35.  
  36. (* Calling Conventions *)
  37.     
  38. TYPE
  39.     CallingConventionType* = INTEGER;
  40.  
  41.  
  42. CONST
  43.     kPascalStackBased*            = 0;
  44.     kCStackBased*                = 1;
  45.     kRegisterBased*                = 2;
  46.     kD0DispatchedPascalStackBased* = 8;
  47.     kD1DispatchedPascalStackBased* = 12;
  48.     kD0DispatchedCStackBased*    = 9;
  49.     kStackDispatchedPascalStackBased* = 14;
  50.     kThinkCStackBased*            = 5;
  51.  
  52. (* ISA Types *)
  53.     
  54. TYPE
  55.     ISAType* = Types.SInt8;
  56.  
  57.  
  58. CONST
  59.     kM68kISA*                    = 0;
  60.     kPowerPCISA*                    = 1;
  61.  
  62. (* RTA Types *)
  63.     
  64. TYPE
  65.     RTAType* = Types.SInt8;
  66.  
  67.  
  68. CONST
  69.     kOld68kRTA*                    = 0 * (16);
  70.     kPowerPCRTA*                    = 0 * (16);
  71.     kCFM68kRTA*                    = 1 * (16);
  72.  
  73. (*$IF GENERATINGPOWERPC *)
  74.     GetCurrentISA*                = kPowerPCISA;
  75.     GetCurrentRTA*                = kPowerPCRTA;
  76.  
  77. (*$ELSE*)
  78. (*$IF GENERATINGCFM *)
  79.     GetCurrentISA*                = kM68kISA;
  80.     GetCurrentRTA*                = kCFM68kRTA;
  81.  
  82. (*$ELSE*)
  83.     GetCurrentISA*                = kM68kISA;
  84.     GetCurrentRTA*                = kOld68kRTA;
  85.  
  86. (*$END*)
  87. (*$END*)
  88.     GetCurrentArchitecture*        = 0+(GetCurrentISA + GetCurrentRTA);
  89.  
  90.     kRegisterD0*                    = 0;
  91.     kRegisterD1*                    = 1;
  92.     kRegisterD2*                    = 2;
  93.     kRegisterD3*                    = 3;
  94.     kRegisterD4*                    = 8;
  95.     kRegisterD5*                    = 9;
  96.     kRegisterD6*                    = 10;
  97.     kRegisterD7*                    = 11;
  98.     kRegisterA0*                    = 4;
  99.     kRegisterA1*                    = 5;
  100.     kRegisterA2*                    = 6;
  101.     kRegisterA3*                    = 7;
  102.     kRegisterA4*                    = 12;
  103.     kRegisterA5*                    = 13;
  104.     kRegisterA6*                    = 14;
  105. (* A7 is the same as the PowerPC SP *)
  106.     kCCRegisterCBit*                = 16;
  107.     kCCRegisterVBit*                = 17;
  108.     kCCRegisterZBit*                = 18;
  109.     kCCRegisterNBit*                = 19;
  110.     kCCRegisterXBit*                = 20;
  111.  
  112.     
  113. TYPE
  114.     registerSelectorType* = INTEGER;
  115.  
  116. (* SizeCodes we use everywhere *)
  117.  
  118. CONST
  119.     kNoByteCode*                    = 0;
  120.     kOneByteCode*                = 1;
  121.     kTwoByteCode*                = 2;
  122.     kFourByteCode*                = 3;
  123.  
  124. (* Mixed Mode Routine Records *)
  125.     
  126. TYPE
  127.     ProcInfoType* = LONGINT;
  128.  
  129. (* Routine Flag Bits *)
  130.     RoutineFlagsType* = INTEGER;
  131.  
  132.  
  133. CONST
  134.     kProcDescriptorIsAbsolute*    = $00;
  135.     kProcDescriptorIsRelative*    = $01;
  136.  
  137.     kFragmentIsPrepared*            = $00;
  138.     kFragmentNeedsPreparing*        = $02;
  139.  
  140.     kUseCurrentISA*                = $00;
  141.     kUseNativeISA*                = $04;
  142.  
  143.     kPassSelector*                = $0;
  144.     kDontPassSelector*            = $08;
  145.  
  146.     kRoutineIsNotDispatchedDefaultRoutine* = $0;
  147.     kRoutineIsDispatchedDefaultRoutine* = $10;
  148.  
  149.  
  150. TYPE
  151.     RoutineRecord* = RECORD
  152.         procInfo*:                ProcInfoType;                            (* calling conventions *)
  153.         reserved1*:                Types.SInt8;                                    (* Must be 0 *)
  154.         ISA*:                    ISAType;                                (* Instruction Set Architecture *)
  155.         routineFlags*:            RoutineFlagsType;                        (* Flags for each routine *)
  156.         procDescriptor*:            Types.ProcPtr;                                (* Where is the thing we’re calling? *)
  157.         reserved2*:                LONGINT;                                (* Must be 0 *)
  158.         selector*:                LONGINT;                                (* For dispatched routines, the selector *)
  159.     END;
  160.  
  161.     RoutineRecordPtr* = POINTER TO RoutineRecord;
  162.     RoutineRecordHandle* = HANDLE TO RoutineRecord (*ΔΔ POINTER TO RoutineRecordPtr*);
  163.  
  164. (* Mixed Mode Routine Descriptors *)
  165. (* Definitions of the Routine Descriptor Flag Bits *)
  166.     RDFlagsType* = Types.UInt8;
  167.  
  168.  
  169. CONST
  170.     kSelectorsAreNotIndexable*    = $00;
  171.     kSelectorsAreIndexable*        = $01;
  172.  
  173. (* Routine Descriptor Structure *)
  174.  
  175. TYPE
  176.     RoutineDescriptor* = (*ΔΔPACKEDΔΔ*) RECORD
  177.         goMixedModeTrap*:        INTEGER;                                (* Our A-Trap *)
  178.         version*:                Types.SInt8;                                    (* Current Routine Descriptor version *)
  179.         routineDescriptorFlags*:    RDFlagsType;                            (* Routine Descriptor Flags *)
  180.         reserved1*:                LONGINT;                                (* Unused, must be zero *)
  181.         reserved2*:                Types.UInt8;                                    (* Unused, must be zero *)
  182.         selectorInfo*:            Types.UInt8;                                    (* If a dispatched routine, calling convention, else 0 *)
  183.         routineCount*:            INTEGER;                                (* Number of routines in this RD *)
  184.         routineRecords*:            ARRAY 1 (*ΔΔ[0..0]ΔΔ*) OF RoutineRecord;            (* The individual routines *)
  185.     END;
  186.  
  187.     RoutineDescriptorPtr* = POINTER TO RoutineDescriptor;
  188.     RoutineDescriptorHandle* = HANDLE TO RoutineDescriptor (*ΔΔ POINTER TO RoutineDescriptorPtr*);
  189.  
  190.  
  191. CONST
  192. (* Calling Convention Offsets *)
  193.     kCallingConventionWidth*        = 4;
  194.     kCallingConventionPhase*        = 0;
  195.     kCallingConventionMask*        = $F;
  196. (* Result Offsets *)
  197.     kResultSizeWidth*            = 2;
  198.     kResultSizePhase*            = kCallingConventionWidth;
  199.     kResultSizeMask*                = $30;
  200. (* Parameter offsets & widths *)
  201.     kStackParameterWidth*        = 2;
  202.     kStackParameterPhase*        = 0+(kCallingConventionWidth + kResultSizeWidth);
  203.     kStackParameterMask*            = $FFFFFFC0;
  204. (* Register Result Location offsets & widths *)
  205.     kRegisterResultLocationWidth* = 5;
  206.     kRegisterResultLocationPhase* = 0+(kCallingConventionWidth + kResultSizeWidth);
  207. (* Register Parameter offsets & widths *)
  208.     kRegisterParameterWidth*        = 5;
  209.     kRegisterParameterPhase*        = 0+(kCallingConventionWidth + kResultSizeWidth + kRegisterResultLocationWidth);
  210.     kRegisterParameterMask*        = $7FFFF800;
  211.     kRegisterParameterSizePhase*    = 0;
  212.     kRegisterParameterSizeWidth*    = 2;
  213.     kRegisterParameterWhichPhase* = kRegisterParameterSizeWidth;
  214.     kRegisterParameterWhichWidth* = 3;
  215. (* Dispatched Stack Routine Selector offsets & widths *)
  216.     kDispatchedSelectorSizeWidth* = 2;
  217.     kDispatchedSelectorSizePhase* = 0+(kCallingConventionWidth + kResultSizeWidth);
  218. (* Dispatched Stack Routine Parameter offsets *)
  219.     kDispatchedParameterPhase*    = 0+(kCallingConventionWidth + kResultSizeWidth + kDispatchedSelectorSizeWidth);
  220. (* Special Case offsets & widths *)
  221.     kSpecialCaseSelectorWidth*    = 6;
  222.     kSpecialCaseSelectorPhase*    = kCallingConventionWidth;
  223.     kSpecialCaseSelectorMask*    = $3F0;
  224. (* Components.Component Manager Special Case offsets & widths *)
  225.     kComponentMgrResultSizeWidth* = 2;
  226.     kComponentMgrResultSizePhase* = kCallingConventionWidth + kSpecialCaseSelectorWidth; (* 4 + 6* = 10 *)
  227.     kComponentMgrParameterWidth*    = 2;
  228.     kComponentMgrParameterPhase*    = kComponentMgrResultSizePhase + kComponentMgrResultSizeWidth; (* 10 + 2* = 12 *)
  229.  
  230.     kSpecialCase*                = $0000000F;
  231.  
  232. (* all of the special cases enumerated.  The selector field is 6 bits wide *)
  233.     kSpecialCaseHighHook*        = 0;
  234.     kSpecialCaseCaretHook*        = 0;                            (* same as kSpecialCaseHighHook *)
  235.     kSpecialCaseEOLHook*            = 1;
  236.     kSpecialCaseWidthHook*        = 2;
  237.     kSpecialCaseTextWidthHook*    = 2;                            (* same as kSpecialCaseWidthHook *)
  238.     kSpecialCaseNWidthHook*        = 3;
  239.     kSpecialCaseDrawHook*        = 4;
  240.     kSpecialCaseHitTestHook*        = 5;
  241.     kSpecialCaseTEFindWord*        = 6;
  242.     kSpecialCaseProtocolHandler*    = 7;
  243.     kSpecialCaseSocketListener*    = 8;
  244.     kSpecialCaseTERecalc*        = 9;
  245.     kSpecialCaseTEDoText*        = 10;
  246.     kSpecialCaseGNEFilterProc*    = 11;
  247.     kSpecialCaseMBarHook*        = 12;
  248.     kSpecialCaseComponentMgr*    = 13;
  249.  
  250. (*$IF GENERATINGCFM *)
  251.  
  252. PROCEDURE NewRoutineDescriptor*(theProc: Types.ProcPtr; theProcInfo: ProcInfoType; theISA: ByteParameter): UniversalProcPtr;
  253.     (*$IF NOT GENERATINGCFM*)
  254.     INLINE PASCAL $7000, $AA59;
  255.     (*$END*)
  256. PROCEDURE DisposeRoutineDescriptor*(theProcPtr: UniversalProcPtr);
  257.     (*$IF NOT GENERATINGCFM*)
  258.     INLINE PASCAL $7001, $AA59;
  259.     (*$END*)
  260. PROCEDURE NewFatRoutineDescriptor*(theM68kProc: Types.ProcPtr; thePowerPCProc: Types.ProcPtr; theProcInfo: ProcInfoType): UniversalProcPtr;
  261.     (*$IF NOT GENERATINGCFM*)
  262.     INLINE PASCAL $7002, $AA59;
  263.     (*$END*)
  264. (*$ELSE*)
  265.  
  266. PROCEDURE NewRoutineDescriptor*(theProc: Types.ProcPtr; theProcInfo: ProcInfoType; theISA: Types.ByteParameter): Types.UniversalProcPtr;
  267.     (*$IF NOT GENERATINGCFM*)
  268.     INLINE PASCAL $5C4F, $2E9F;
  269.     (*$END*)
  270. PROCEDURE DisposeRoutineDescriptor*(theProcPtr: Types.UniversalProcPtr);
  271.     (*$IF NOT GENERATINGCFM*)
  272.     INLINE PASCAL $584F;
  273.     (*$END*)
  274. (*$END*)
  275. (*$IF CFMSYSTEMCALLS *)
  276. (*$IF NOT LSPWRP & NOT LSP68K*)
  277. PROCEDURE CallUniversalProc*(theProcPtr: Types.UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C;
  278. PROCEDURE CallOSTrapUniversalProc*(theProcPtr: Types.UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C;
  279. (*$END*)
  280. (*$END*)
  281.  
  282. (* $ALIGN RESET*)
  283. (* $POP*)
  284.  
  285.  END MixedMode.
  286.